package com.xwltz.rbac.auth;

import cn.dev33.satoken.stp.StpInterface;
import com.xwltz.core.utils.ConvertUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description AuthImpl
 * @information on version 1.0 be created by @xwltz at 2022/6/17 17:09
 */

@Component
public class AuthImpl implements StpInterface {
	@Override
	public List<String> getPermissionList(Object o, String s) {
		// 本list仅做模拟，实际项目中要根据具体业务逻辑来查询权限
		List<String> list = new ArrayList<>();
		if (ConvertUtils.toLong(o) == 1) {
			list.add("album");
			list.add("album:index");
		} else {
			list.add("album");
			list.add("album:getById");
		}
		return list;
	}

	@Override
	public List<String> getRoleList(Object o, String s) {
		// 本list仅做模拟，实际项目中要根据具体业务逻辑来查询角色
		List<String> list = new ArrayList<>();
		list.add("admin");
		list.add("super-admin");
		return list;
	}
}
